#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vi: ts=4 expandtab
#
# Copyright (C) 2012 KT
#
# Author: Choonho Son <choonho.son@kt.com>
#

import subprocess

__version__="1.0"

class cmd_disk:
	def __init__(self, logger):
		self.logger = logger

	def createPV(self, dev):
		"""
		create physical volume
		@params dev : device name (ex. /dev/xvdb)
		"""
		cmd = [ 'pvcreate', dev ]
		self.logger.debug("cmd:%s" % cmd)
		proc = subprocess.Popen(cmd)
		proc.communicate()

	def add2known_hosts(self, pubKey, dst):
		"""
		@param pubKey : public Key file path
		@param dst : destination path (known_hosts)
		"""
		fp = open(pubKey,'r')
		dstfp = open(dst, 'a+')
		dstfp.write(fp.read())
		fp.close()
		dstfp.close()
